package com.canbot.u05.adapter.meeting;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.canbot.u05.R;
import com.canbot.u05.bean.meeting.Linkman;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lrh on 2017/3/3.
 */

public class MeetingCallListViewAdapter extends BaseAdapter {

        private List<Linkman> dList = new ArrayList<Linkman>();

        private Context context;

        private LayoutInflater mInflater;


        public MeetingCallListViewAdapter(Context context, List<Linkman> dList) {
                super();
                this.context = context;
                mInflater = LayoutInflater.from(context);
                this.dList = dList;
        }

        @Override
        public int getCount() {
                return dList.size();
        }

        @Override
        public Linkman getItem(int position) {
                return dList.get(position);
        }

        @Override
        public long getItemId(int position) {
                return position;
        }

        //然后重写getView
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

                ViewHolder holder = null;
                if (convertView == null) {
                        holder = new ViewHolder();
                        convertView = mInflater.inflate(R.layout.layout_meeting_call_linkman, null);
                        holder.name = (TextView) convertView.findViewById(R.id.call_name);
                        holder.callNum = (TextView) convertView.findViewById(R.id.call_num);
                        holder.icon = (ImageView) convertView.findViewById(R.id.call_name_icon);
                        convertView.setTag(holder);
                }
                else {
                        holder = (ViewHolder) convertView.getTag();
                }
                Linkman linkman = dList.get(position);
                holder.name.setText(linkman.getName());
                holder.callNum.setText(linkman.getCallNum());
                return convertView;
        }


        private class ViewHolder {

                private TextView name;

                private TextView callNum;

                private ImageView icon;

        }

}
